package com.softer.wxzj.controller;

import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.entity.FileClassify;
import com.softer.wxzj.entity.MaintenanceObject;
import com.softer.wxzj.service.MaintenanceObjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 维修对象类别
 *
 * @author Gong Zhiyang
 * @date 2019/7/16
 */
@RestController
@RequestMapping("/maintenanceObject")
public class MaintenanceObjectController {
    @Autowired
    private MaintenanceObjectService maintenanceObjectService;

    /**
     * 新增维修对象类别
     *
     * @param maintenanceObject 维修对象
     * @return 结果
     */
    @PostMapping("/add")
    public CommonResult add(MaintenanceObject maintenanceObject) {
        return maintenanceObjectService.add(maintenanceObject);
    }

    /**
     * 查询维修对象
     *
     * @param id 维修对象ID
     * @return 维修对象
     */
    @PostMapping("/getInfo")
    public MaintenanceObject getInfo(String id) {
        return maintenanceObjectService.getInfo(id);
    }

    /**
     * 删除维修对象
     *
     * @param id 维修对象ID
     * @return 删除结果
     */
    @PostMapping("/delete")
    public CommonResult delete(String id) {
        return maintenanceObjectService.delete(id);
    }

    /**
     * 修改维修对象类别
     *
     * @param maintenanceObject 维修对象
     * @return 结果
     */
    @PostMapping("/update")
    public CommonResult update(MaintenanceObject maintenanceObject) {
        return maintenanceObjectService.update(maintenanceObject);
    }

    /**
     * 获取公共设施设备分类的左侧三级菜单
     *
     * @return 三级菜单
     */
    @RequestMapping("/getMaintenanceObjectList")
    public FileClassify getMaintenanceObjectList() {
        return maintenanceObjectService.getMaintenanceObjectList();
    }

    /**
     * 获取有效的公共设施设备分类的三级菜单
     * 用于维修资金使用的项目新建选择
     *
     * @return 三级菜单
     */
    @RequestMapping("/getEffectiveMaintenanceObjectList")
    public FileClassify getEffectiveMaintenanceObjectList(String projectType) {
        return maintenanceObjectService.getEffectiveMaintenanceObjectList(projectType);
    }
}
